{% extends "admin/base_site.html" %}
{% load adminmedia admin_list i18n %}

{% block extrastyle %}
  {{ block.super }}
  <link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/changelists.css" />
  {% if cl.formset %}
    <link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/forms.css" />
    {% url admin:jsi18n as jsi18nurl %}
    <script type="text/javascript" src="{{ jsi18nurl|default:'../../jsi18n/' }}"></script>
  {% endif %}
  {{ media }}
  {% if not actions_on_top and not actions_on_bottom %}
    <style>
      #changelist table thead th:first-child {width: inherit}
    </style>
  {% endif %}
{% endblock %}

{% block bodyclass %}change-list{% endblock %}

{% if not is_popup %}
  {% block breadcrumbs %}
    <div class="breadcrumbs">
      <a href="/admin">
        Home
      </a>
       &rsaquo; 
       <a href="/admin/econ_analysis">
         Econ_analysis
      </a>
       &rsaquo; 
       <a href="/admin/econ_analysis/fishingimpactcache">
         Fishing impact caches 
      </a>
      &rsaquo; 
         Run Analysis on Users
    </div>
  {% endblock %}
{% endif %}

{% block coltype %}flex{% endblock %}

{% block content %}
  {% if complete %}
      <p>Analysis has been run on all mpas owned by the following:</p>
      {% for user in users %}
        <br/>{{ user }} ..... Done
      {% endfor %}
  {% else %}
      <div id="content-main">
        <div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
          <p>Select one or more Users from the select box below:</p>
          <form action="/econ_analysis/adminUserAnalysis/" method="post">
            {{ form.as_p }}
            <p>WARNING:  Running Analysis can take a VERY LONG TIME!  
            <br/>It takes roughly 3 MINUTES to run full impact analysis ON A SINGLE MPA.  
            <br/>If you run the analysis on 2 Users that each own 10 MPAs, this translates to ONE HOUR of potential processing time.
            <br/>(This may be quicker if the analysis has already been run for some or all of the MPAs owned by the selected Users.)</p>
            <p>For a (very) rough estimate of the time this will take to process, start with the Estimate Processing Time button</p>
            <p>***ESTIMATE THE PROCESSING TIME BEFORE YOU RUN THE ANALYSIS!***</p>
            <input type="submit" name="estimate" value="Estimate Processing Time" />
            <input type="submit" name="process" value="Run Impact Analysis" />
          </form>
          {% for user, time in processing_times.items %}
            <br/>Estimated Processing Time for {{ user.username }} ..... {{ time }}
          {% endfor %}
          {% if total_time %}
            <br/><b>Total Processing Time ..... {{ total_time }}</b>
          {% endif %}
        </div>
      </div>
  {% endif %}
{% endblock %}
